<!--
 * @Author: luobei luobei@seewintech.com
 * @Date: 2023-02-23 20:11:19
 * @LastEditors: luobei luobei@seewintech.com
 * @LastEditTime: 2023-02-23 20:26:47
 * @FilePath: \ibuilds-web-system\src\views\systemManage\formManage\formDesign\packages\config\custom.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <div class="el-form-item el-form-item--small el-form--label-top">
      <label
        class="el-form-item__label"
        style="padding: 0;"
      >自定义属性：</label>
      <div class="el-form-item__content">
        <monaco-editor
          v-model="params"
          height="300"
          :key-index="data.prop"
          :options="options"
        />
      </div>
    </div>
    <div class="el-form-item el-form-item--small el-form--label-top">
      <label
        class="el-form-item__label"
        style="padding: 0;"
      >自定义事件：</label>
      <div class="el-form-item__content">
        <monaco-editor
          v-model="event"
          height="300"
          :key-index="data.prop"
          :options="options"
        />
      </div>
    </div>
  </div>
</template>
<script>
import MonacoEditor from '../utils/monaco-editor'

export default {
  name: 'ConfigCustom',
  components: { MonacoEditor },
  props: ['data'],
  data() {
    return {
      params: this.data.params || {},
      event: this.data.event || {},
      options: {
        fullScreen: true,
        minimap: {
          enabled: false,
        },
      },
    }
  },
  watch: {
    'data.params'(val) {
      this.params = val || {}
    },
    'data.event'(val) {
      this.event = val || {}
    },
    params(val) {
      try {
        this.data.params = eval('(' + val + ')')
      } catch (e) {
        // console.error(e)
      }
    },
    event(val) {
      try {
        this.data.event = eval('(' + val + ')')
      } catch (e) {
        // console.error(e)
      }
    },
  }
}
</script>
